<template>
  <div class="top-navbar-component" :style="componentStyle">
    <div class="navbar-logo" v-if="显示Logo">
      <img v-if="Logo图片" :src="Logo图片" alt="Logo" class="logo-image">
      <span v-else class="logo-text">{{ Logo文字 }}</span>
    </div>
    <div class="navbar-menu">
      <div 
        v-for="(item, index) in 菜单项目" 
        :key="index"
        class="menu-item"
        :class="{ 'active': index === 0 }"
      >
        {{ item }}
      </div>
    </div>
    <div class="navbar-actions" v-if="显示操作区">
      <i class="el-icon-search"></i>
      <i class="el-icon-user"></i>
    </div>
  </div>
</template>

<script>
export default {
  name: 'TopNavbar1Component',
  componentName: '顶部导航栏1',
  icon: 'el-icon-menu',
  defaultProps: {
    背景颜色: '#ffffff',
    文字颜色: '#333333',
    高亮颜色: '#409EFF',
    显示Logo: true,
    Logo文字: 'LOGO',
    Logo图片: '',
    菜单项目: ['首页', '产品', '服务', '关于我们', '联系我们'],
    显示操作区: true
  },
  props: {
    背景颜色: {
      type: String,
      default: '#ffffff'
    },
    文字颜色: {
      type: String,
      default: '#333333'
    },
    高亮颜色: {
      type: String,
      default: '#409EFF'
    },
    显示Logo: {
      type: Boolean,
      default: true
    },
    Logo文字: {
      type: String,
      default: 'LOGO'
    },
    Logo图片: {
      type: String,
      default: ''
    },
    菜单项目: {
      type: Array,
      default: () => ['首页', '产品', '服务', '关于我们', '联系我们']
    },
    显示操作区: {
      type: Boolean,
      default: true
    }
  },
  computed: {
    componentStyle() {
      return {
        backgroundColor: this.背景颜色,
        color: this.文字颜色,
        width: '100%',
        height: '100%',
        boxSizing: 'border-box'
      };
    }
  }
};
</script>

<style scoped>
.top-navbar-component {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-logo {
  display: flex;
  align-items: center;
  font-size: 1.5rem;
  font-weight: bold;
}

.logo-image {
  height: 32px;
  max-width: 100px;
  object-fit: contain;
}

.navbar-menu {
  display: flex;
  gap: 20px;
}

.menu-item {
  padding: 10px 0;
  cursor: pointer;
  position: relative;
}

.menu-item.active {
  color: v-bind(高亮颜色);
  font-weight: bold;
}

.menu-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: v-bind(高亮颜色);
}

.navbar-actions {
  display: flex;
  gap: 15px;
  font-size: 1.2rem;
}

.navbar-actions i {
  cursor: pointer;
}
</style>